<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page import="java.sql.*"%>
<%@ page import="schronisko.*,Users.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="../styles/forms.css">
<style>
body {
	background: #c6b154;
}
</style>
<title>Wystaw opinie</title>
</head>
<body>
<% 
Queries q = new Queries();
if(session.getAttribute("ID") != null){ %>
<a href="../Panel/Panel.jsp"> Powrot do panelu</a>
<center>
<%
int noted = 0;
try {
	noted = (Integer)session.getAttribute("noted");
}
catch(NullPointerException e){
}
switch(noted){
case 0:
	if(q.ifNoted((Integer)session.getAttribute("ID"))){
		out.println("<h1>Wystawiles juz opinie. Dziekujemy za to</h1><br>Mozesz ja, a takze inne zobaczyc <a href='../notes.jsp'>tutaj</a>");
	}
	else {
		%>
<h1>Jak oceniasz nasze schronisko? Twoje zdanie jest dla nas bardzo wazne!</h1>
<form method = "post" action="../Notes"  class='form-container'>
<div class="form-title"><h2>Opinia</h2></div>
<textarea id="msg" name="msg" cols="150" rows="20" class="form-field"></textarea>
<div class="form-title"><h2>Ocena</h2></div>
1 <input id='note' name='note' type='radio' value='1'>
2 <input id='note' name='note' type='radio' value='2'>
3 <input id='note' name='note' type='radio' value='3'>
4 <input id='note' name='note' type='radio' value='4'>
5 <input id='note' name='note' type='radio' value='5'>
<input id='id' name='id' type='hidden' value=<% out.println(session.getAttribute("ID")); %>>
<input id='type' name='type' type='hidden' value='submit'>
<div class="submit-container">
<input class="submit-button" type='submit' value='Wystaw'>
</div>
</form>
		
		<%
	}
	break;
case 1:
	out.println("Dziekujemy za wystawienie opinii");
	out.println("<h1>Wystawiles juz opinie. Dziekujemy za to</h1><br>Mozesz ja, a takze inne zobaczyc <a href='../notes.jsp'>tutaj</a>");
	session.setAttribute("noted", 0);
	break;
case 2:
	out.println("Problemy z serwerem. Prosze sprobowac pozniej");
	session.setAttribute("noted", 0);
	break;
case 3:
	out.println("Problem z baza danych. Prosze sprobowac pozniej");
	session.setAttribute("noted", 0);
	break;
}
%>
</center>
<%
}
else {
	out.println("<div class='menu'><b>Sesja wygasla.</b><br> Za 3 sec nastapi przeniesienie do strony logowania <br> Kliknij, jesli nie zadziala:<br> <a href = '../index.jsp'> Wroc do strony glownej</a></div>");
	response.setHeader("Refresh", "3; URL=../index.jsp");
}
%>
</body>
</html>